package com.robot.base.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

import com.blankj.utilcode.util.LanguageUtils;
import com.robot.base.R;

import java.util.Locale;

public class CgTextView extends TextView {

    public CgTextView(Context context) {
        super(context);
    }

    public CgTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CgTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CgTextView);
        int textType = typedArray.getInt(R.styleable.CgTextView_cgTextStyle,-1);
        switch (textType){
            case 0:
                setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Alibaba-PuHuiTi-Bold.otf"));
                break;
            case 1:
                setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Alibaba-PuHuiTi-Heavy.otf"));
                break;
            case 2:
                setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Alibaba-PuHuiTi-Light.otf"));
                break;
            case 3:
                setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Alibaba-PuHuiTi-Medium.otf"));
                break;
            case 4:
                setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Alibaba-PuHuiTi-Regular.otf"));
                break;
        }
    }
}